package 算法回顾;

/**
 * @description: 小白白刷题
 * @author: 小白白
 * @create: 2021-09-08
 **/

public class JZ10斐波那契数列 {

    private int[] dp;

    public int fib(int n) {

        this.dp = new int[n + 4];
        this.dp[0] = 0;
        this.dp[1] = 1;
        this.dp[2] = 1;

        for (int i = 3; i <= n; i++) {
            this.dp[i] = (this.dp[i - 1] + this.dp[i - 2]) % 1000000007;
        }

        return this.dp[n];
    }

}
